<%--
  Created by IntelliJ IDEA.
  User: 10330
  Date: 2021/6/28
  Time: 14:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>


<head>
    <title>随意购商城</title>

    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/bootstrap/css/default.css">

    <!-- <link rel="stylesheet" href="${pageContext.request.contextPath}/css/carousel.css" > -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/style.css" >

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="${pageContext.request.contextPath}/resources/js/jquery-1.11.3.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script	src="${pageContext.request.contextPath}/resources/css/bootstrap/js/bootstrap.min.js"></script>
    <!-- <script src="${pageContext.request.contextPath}/js/common.js"></script> -->

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
</head>

<script>
    $(function (){
        let user = "${sessionScope.get("_LOGIN_USER_").user_name}";
        if(user !== '' && user !== 'null'){
            $("#info").html("<li id='li1'><span>${sessionScope.get("_LOGIN_USER_").user_name} 您好，欢迎来到随意购商城！</span>"+
                "<li><a href='#' onclick='showCart()'>购物车 <span class='badge' id='cartBadge'>${sessionScope.cartGoodsList.size()}</span></a></li>"+
                "<li><a href='${pageContext.request.contextPath}/order/getMyOrders'>我的订单</a></li>"+
                "<li><a href='${pageContext.request.contextPath}/pages/user/userCenter.jsp?action=userInformation'>个人中心</a></li>"+
                "<li><a href='#' onclick='logout()'>退出登录</a></li>");
        }
    })
</script>


<body>

<%@include file="/pages/user/loginFromModal.jsp"%>
<%@include file="/pages/user/registerFromModal.jsp"%>
<%@include file="/pages/user/msg.jsp"%>
<%@include file="/pages/user/cartModal.jsp"%>

<div class="container">

    <div class="row clearfix">
        <div class="col-md-12 ">
            <br>
            <%--            后续在此继续编写项目通用头部内容，包括登录、退出、购物车、项目导航栏等内容。--%>
            <ol class="breadcrumb text-right" id="info">
                <li id="li1">
                    <span>游客您好，欢迎来到随意购商城！</span>
                    <a href="#loginFormModal" data-toggle="modal">[登录]</a>&nbsp;<a href="#regFormModal" data-toggle="modal">[新用户注册]</a>
                </li>

                <li>
                    <a href="#" onclick="">购物车 <span class="badge" id="cartBadge"></span></a>
                </li>
            </ol>

            <nav class="navbar navbar-default" role="navigation">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                        <span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="${pageContext.request.contextPath}/home?action=index"><span class="logo">随意购</span> 商城</a>
                </div>

                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">
                        <li class="active">
                            <a href="${pageContext.request.contextPath}/home?action=index">首页</a>
                        </li>
                        <li> <a href="${pageContext.request.contextPath}/goods?action=saleGoods">热销商品</a></li>
                        <li> <a href="${pageContext.request.contextPath}/goods?action=newGoods">新到商品</a></li>

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">商品分类<strong class="caret"></strong></a>
                            <ul class="dropdown-menu">
                                <c:forEach items="${categoryDetailListForHeader}" var="categoryDetail">
                                    <c:forEach items="${categoryDetail.childList}" var="child">
                                        <li><a href="${pageContext.request.contextPath}/goods?action=goodsCate&cateId=${child.childId}">${child.childName}</a></li>
                                    </c:forEach>
                                    <li class="divider"></li>
                                </c:forEach>
                            </ul>
                        </li>
                    </ul>
                    <form method="post" action="${pageContext.request.contextPath}/goods?action=search" class="navbar-form navbar-left" role="search">
                        <div class="form-group">
                            <input type="text" name="searchContent" class="form-control" />
                        </div> <button type="submit" class="btn btn-default">店内搜索</button>
                    </form>
                    <ul class="nav navbar-nav navbar-right">

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">排序<strong class="caret"></strong></a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a href="${pageContext.request.contextPath}/goods?action=goodsSort&cateId=${param.cateId}&searchContent=${param.searchContent}&sort=1">按价格从低到高</a>
                                </li>
                                <li>
                                    <a href="${pageContext.request.contextPath}/goods?action=goodsSort&cateId=${param.cateId}&searchContent=${param.searchContent}&sort=2">按价格从高到低</a>
                                </li>
                                <li class="divider"></li>
                                <li>
                                    <a href="${pageContext.request.contextPath}/goods?action=goodsSort&cateId=${param.cateId}&searchContent=${param.searchContent}&sort=3">按销量从高到低</a>
                                </li>
                                <li>
                                    <a href="${pageContext.request.contextPath}/goods?action=goodsSort&cateId=${param.cateId}&searchContent=${param.searchContent}&sort=4">按销量从低到高</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>

            </nav>


            <br>
        </div>
    </div>
